const getters = {
    shopList:state => state.shop_List,
    cartProducts:(state)=>{
      return state.list.map((obj)=>{
        let product = state.shop_List.find(n=>n.id == obj.id);
        console.info('product',product);
        return {
          ...product,
          num:obj.num
        }
      })
    },
    totalNum:(state,getters)=>{
      let num = 0;
      getters.cartProducts.forEach((item)=>{
        num+=item.num
      });
      return num
    },
    totalPrice:(state,getters)=>{
      let price = 0;
      getters.cartProducts.forEach((item)=>{
        price+=item.price*item.num
      });
      return price
    }
};

export default getters
